package com.cnbm.modules.opcua.selfunion;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Test {
    public static void main(String[] args) throws Exception {
 /*
        //1.测试读且 单个变量
        UAService uaService = new UAService();
        DataValue valueByName = uaService.getValueByName(PLCVar.INT32_3);
        System.out.println(valueByName.getValue().getValue());
 */

/*
        //2.测试读且 多个变量
        UAService uaService = new UAService();
        List<DataValue> values = uaService.getValues(PLCVar.Boolean_3,PLCVar.INT32_3);
        for(DataValue i:values){
            System.out.println(i.getValue().getValue());
        }*/
/*

        //3.write   一次性 写一个变量
        UAService uaService = new UAService();
        boolean valueByName = uaService.setValue(PLCVar.INT32_3,11);
        System.out.println(valueByName);
*/
/*
        //4.write   一次性 写多个变量
        UAService uaService = new UAService();
        List<PLCVar> vars = new ArrayList<>();
        vars.add(PLCVar.INT32_3);
        vars.add(PLCVar.Boolean_3);
        List<Object> values = new ArrayList<>();
        values.add(20);
        values.add(false);

        boolean valueByName = uaService.setValues(vars,values);
        System.out.println(valueByName);*/

        //5.订阅变量
/*
        UAService uaService = new UAService();
        uaService.subscribe(PLCVar.INT32_3,new Double(1000.0),(item, dataValue)->{
            System.err.println("（测试是否 每隔intervel 都会执行这个回调方法） subscription value received: item:NodeId : " +
                    ""+item.getReadValueId().getNodeId()+", value :"+ dataValue.getValue());
            System.out.println();
            if(dataValue.getValue().getValue().equals(11)){
                System.out.println("I AM DONE");
            }

        });

        uaService.subscribe(PLCVar.Boolean_3,new Double(1000.0),(item,dataValue)->{
            System.err.println("（测试是否 每隔intervel 都会执行这个回调方法） subscription value received: item:NodeId : " +
                    ""+item.getReadValueId().getNodeId()+", value :"+ dataValue.getValue());
            System.out.println();
            if(dataValue.getValue().getValue().equals(false)){
                System.out.println("I AM DONE");
            }

        });
        System.out.println("测试subscribe 是否异步");*/

        String a = "a|b";
        String[] split = a.split("\\|");
        System.out.println(split[0]);
        System.out.println(split[1]);
    }
}
